package top.yueyazhui.vhr.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yueyazhui.vhr.mapper.RoleMapper;
import top.yueyazhui.vhr.model.Role;

import java.util.List;

@Service
public class RoleService {

    @Autowired
    RoleMapper roleMapper;

    public List<Role> getAll() {
        return roleMapper.getAll();
    }

    public Integer insert(Role role) {
        if(!role.getName().startsWith("ROLE_")) {
            role.setName("ROLE_" + role.getName());
        }
        return roleMapper.insert(role);
    }

    public Integer delete(Integer id) {
        return roleMapper.deleteByPrimaryKey(id);
    }
}
